home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 14 / Hot Mix 14.iso / HTML / vendors / finesse / examples / sh / xtar < prev   
Text File  |  1996-06-27  |  3KB  |  150 lines

  1. #! /bin/sh
  2. # FINESSEAPPLICATIONKEY sIjfovexnmgN?
  3. #
  4. . ${FINESSEPATH-/usr/local/finesse}/fsshinit
  5. #
  6. create=create
  7. extract=extract
  8. list=list
  9. copy=copy
  10.  
  11. Floppy=Floppy
  12. Exabyte=Exabyte
  13. QIC=QIC
  14. DAT=DAT
  15. DV=File/Directory
  16. DVe=File/Directories
  17.  
  18. windef="
  19.   FsWindow    -name tarwin
  20.               -title xtar
  21.               -btype oxa;
  22.  
  23.   FsSeparator;
  24.  
  25.   FsForm      -name form1;
  26.  
  27.   FsRadio     -label Action: 
  28.               -items '$create $extract $list $copy'
  29.               -parent form1 -var key==$extract;
  30.    
  31.   FsList      -label $DVe: 
  32.               -items '`ls`'
  33.               -nvisible 10
  34.               -include yes
  35.               -mode multiple
  36.               -var filelist=='`ls`';
  37.  
  38.   FsSeparator -name sep1
  39.               -line dashed;
  40.  
  41.   FsForm      -name form2
  42.               -orientation horizontal;
  43.  
  44.   FsRadio     -label Archive: 
  45.               -nrows 5
  46.               -parent form2
  47.               -var archive 
  48.               -items '$Floppy $DV $Exabyte $QIC $DAT';
  49.   
  50.   FsForm -name form3 -parent form2;
  51.  
  52.   FsSeparator -line no -name sep2 -parent form3; 
  53.  
  54.   FsText -var tarfile -parent form3;
  55.   
  56.   FsSeparator -line soliddouble;"
  57.  
  58. Fsopen "$@"                                
  59.  
  60. Fsdisplay -w "$windef" -m " "
  61. if [ "$fsbutton" != "o" ] ; then
  62.   Fsclose; exit
  63. fi
  64.  
  65. # Certain conditions must be met:
  66.  
  67. # 1) list of files must be given
  68.  
  69. testfilelist()
  70. {
  71.   if [ -z "$filelist" ] ; then
  72.     mesg="Please specify $DVe ..."
  73.     return 1   # Error
  74.   else
  75.     return 0   # OK
  76.   fi
  77. }
  78.  
  79.  
  80. # 2) For "Copy" or "File/Directory",
  81. # tar file must be given
  82.  
  83. testtarfile()
  84. {
  85.   if [ "$key" = "$copy" -o "$archive" = "$DV" ] ; then
  86.     if [ -z "$tarfile" ] ; then
  87.       mesg="Please specify $DV ..."
  88.       return 1;  # Error
  89.     else
  90.       return 0;  # OK
  91.     fi
  92.   else
  93.     return 0;    # don't mind
  94.   fi
  95. }
  96.  
  97. # test conditions
  98.  
  99. until testfilelist &&
  100.       testtarfile 
  101. do
  102.   Fsdisplay -n tarwin -m "$mesg"
  103.   if [ "$fsbutton" != "o" ] ; then
  104.     Fsclose; exit
  105.   fi
  106. done
  107.  
  108. # Device file for archive
  109.  
  110. case $archive in
  111.   $Floppy)            dev="f /dev/floppy";;
  112.   $Exabyte)           dev="f /dev/exa";;
  113.   $DAT)               dev="f /dev/dat";;
  114.   $QIC)               dev="f /dev/qic";;
  115.   $DV)                case $key in
  116.                         $copy) dev="$tarfile";;
  117.                         *) dev="f $tarfile";;
  118.                       esac;;
  119. esac
  120.  
  121. # Now the command may be put together
  122.  
  123. case $key in
  124.   $create) com="tar cv$dev $filelist";;
  125.   $extract) com="tar xv$dev $filelist";;
  126.   $list) com="tar t$dev $filelist";;
  127.   $copy)  com="tar cf - $filelist | (cd $dev; tar xf -)";;
  128. esac
  129.  
  130. # final hint
  131.  
  132. case $key in
  133.   $create|$extract|$list) 
  134.     Fsdisplay -w "FsWindow -btype oa;" -m "Medium inserted?" 
  135.     if [ "$fsbutton" != "o" ] ; then
  136.       Fsclose; exit
  137.     fi;;
  138. esac
  139.  
  140. # just pretend to do
  141. #
  142.  
  143. Fsecho "Command:"
  144. Fsecho   $com
  145. Fsecho started.
  146.  
  147. sleep 5
  148.  
  149. Fsclose
  150.